# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=qt5-scxml
_basever=5.15.18
pkgver=5.15.18
pkgrel=3
_commit=57491f554bc53bd020978b5744437b7ac7e56a27
arch=('x86_64' 'aarch64')
url='https://www.qt.io'
license=('GPL-3.0-only' 'LGPL-3.0-only' 'FDL' 'custom')
pkgdesc='Static and runtime integration of SCXML models into Qt code.'
depends=('qt5-declarative')
makedepends=('git')
_pkgfqn=${pkgname/5-/}
source=("kde-$_pkgfqn::git+https://invent.kde.org/qt/qt/$_pkgfqn#commit=$_commit")
sha512sums=('4a6b6b413c00eaeb23995416982b12e0022e694f6a58ac5efc068cfea4c07a9729d2d7ec6174c4aeef5fe48a275731fc351a0c9d0bbc235f3592ab5f16410991')

pkgver() {
  cd "kde-$_pkgfqn"

  echo "$_basever+kde+r"`git rev-list --count v$_basever-lts-lgpl..$_commit` |
    sed -e 's|+kde+r0||'
}

prepare() {
  mkdir -p build
}

build() {
  cd build

  qmake "../kde-$_pkgfqn"

  make
}

package() {
  cd build

  make INSTALL_ROOT="$pkgdir" install

  # Drop QMAKE_PRL_BUILD_DIR because reference the build dir
  find "$pkgdir/usr/lib" -type f -name '*.prl' \
    -exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d' {} \;

  install -d "$pkgdir/usr/share/licenses"
  ln -s /usr/share/licenses/qt5-base "$pkgdir/usr/share/licenses/$pkgname"
}

